import {postSysGamemoduleColumn, postSysGamemoduleUpdate} from '$my/code/api/game-module'

export default {
  data() {
    return {
      data: null
    }
  },
  methods: {
    init() {
      this.data = null
      postSysGamemoduleColumn({objKey: this.key}).then(res => {
        this.id = res.id
        const data = this.data = JSON.parse(res.data)
        this.loaded && this.loaded(data)
      })
    },
    onSave(str) {
      const params = {
        id: this.id,
        data: str
      }
      postSysGamemoduleUpdate(params).then(_ => {
        this.$notify.success('保存成功！')
        this.init();
      }).catch(e => {
        this.$notify.error(e.message)
        throw new Error(e)
      })
    }
  },
  mounted() {
    this.init()
  }
}
